<?php
include_once("inc.php");
$act = !empty($_GET['act']) ? trim($_GET['act']) : '';
if($act == 'shouhuo')
{
	$orderstaid = !empty($_GET['orderstaid']) ? intval($_GET['orderstaid']) : '';
	$ordersid = !empty($_GET['ordersid']) ? intval($_GET['ordersid']) : '';
	db_query("update ordersta set zt='已签收' where id=".$orderstaid);
	urlMsg("收货成功","orders_edit.php?id=".$ordersid);
}

if($act == 'zhifu')
{
	$ordersid = !empty($_GET['ordersid']) ? intval($_GET['ordersid']) : '';
	 $ordersta = db_get_all("select * from ordersta where ordersid=".$ordersid." order by id desc");foreach($ordersta as $ordersrow) {
		 
		$gooda=db_get_row("select * from goods where id=".$ordersrow['goodsid']."");

		if($gooda['amount']<$ordersta['nums']){urlMsg($gooda['title']."购买大于库存，请取消订单再重新下单","order.php");die;};
	}

		foreach($ordersta as $ordersrow1) {
			db_query("update goods set amount=amount-".$ordersrow1['nums']." where id=".$ordersrow1["goodsid"]."");
			db_query("update ordersta set zt='已付款' where id=".$ordersrow1['id']."");
		}
	db_query("update orders set zt='已付款' where id=".$ordersid."");

	urlMsg("支付成功","orders_list.php");
}

?>